<template>
    <div class="main-types">
            <div v-for="(v, k) in mainTypes" :key="'mainTypes'+k" class="item" :style="`width: ${size}`" @click="loadSearch(v)">
                <img :src="v.image" alt="">
                <p :style="`color:${v.titleColor}`">{{v.title}}</p>
            </div>
    </div>
</template>

<script>

import {mapState,mapMutations,mapActions} from 'vuex';

export default {
    props:['mainTypes','size'],
    computed:{
        ...mapState(["searchPage"]),
    },
    methods:{
        ...mapMutations(["setSearchFcid","setSearchTitle","setSearchPage","setSearchSort"]),
        loadSearch(e){
            this.setSearchFcid((e.link.match(/[?|&]fcid=([^&]*)/))[1]);
            this.setSearchTitle(e.title);
            this.$router.push("SearchPage");
        }
    },
}
</script>

<style lang="less" scoped>
    .main-types{
        width: 100%;
        display: flex;
        flex-flow: row wrap;
        box-sizing: border-box;
        padding: 0px 15px 0px 15px;
        
        .item{
            box-sizing: border-box;
            padding: 10px ;
            text-align: center;
            img{
                width: 100%;
            }            
            p{
                font-size: 28px;
                width: 100%;
                text-overflow: ellipsis;
                white-space: nowrap;
                overflow: hidden;
            }
        }
    }
</style>
